package cn.numeron.wxarticle.api.wxarticle

import androidx.room.*
import androidx.sqlite.db.SupportSQLiteQuery

@Dao
interface WxArticleDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun save(wxArticles: List<WxArticle>): LongArray

    @Query("SELECT * FROM wx_article ORDER BY share_time DESC LIMIT :limitCount OFFSET :offset")
    suspend fun getSegmentList(
        limitCount: Int,
        offset: Int
    ): List<WxArticle>

    @RawQuery(observedEntities = [WxArticle::class])
    suspend fun findByKeyword(sql: SupportSQLiteQuery): List<WxArticle>

}